﻿
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Text;
using lib.Model;
using lib.DAL;
namespace lib.BLL
{
    public partial class MenuAccess_Bll
    {
        public bool DelMenuAccess(MenuAccess_Model model)
        {
            bool result = false;
            SqlConnection conn;
            using (SqlTransaction trans = SqlHelperWebDAL.CreateSqlTransaction(out conn))
            {
                try
                {
                    //删除本身
                    MenuAccess_Dal.Instance.Delete(trans, model.FdMeAcID.Value);
                    //删除关联菜单的权限
                    MenuCode_Dal.Instance.Delete("fdMeCoCode=@fdMeCoCode", trans, new SqlParameter("@fdMeCoCode", model.FdMeAcCode.Value));
                    //删除权限组中的菜单权限
                    RoleMenuManage_Dal.Instance.Delete("fdRoleMenuRoleCode=@fdRoleMenuRoleCode", trans, new SqlParameter("@fdRoleMenuRoleCode", model.FdMeAcCode.Value));
                    
                    trans.Commit();
                    result = true;
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                }
                finally
                {
                    conn.Close();
                }
            }
            return result;
        }
    }
}

